package com.yanqu.road.entity.hunt;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.config.hunt.HuntBoxReward;
import com.yanqu.road.utils.string.StringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class HuntBox extends DataObject {

    private String huntBoxUid;

    private long userId;

    private long createTime;

    private int goodsBoxId;

    private List<HuntBoxReward> huntBoxRewardList;

    private List<Long> openUserIdList = new ArrayList<>();

    public String getHuntBoxUid() {
        return huntBoxUid;
    }

    public void setHuntBoxUid(String huntBoxUid) {
        if(!Objects.equals(this.huntBoxUid, huntBoxUid)) {
            this.huntBoxUid = huntBoxUid;
            setUpdateOption();
        }
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if(this.userId != userId) {
            this.userId = userId;
            setUpdateOption();
        }
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        if(this.createTime != createTime) {
            this.createTime = createTime;
            setUpdateOption();
        }
    }

    public int getGoodsBoxId() {
        return goodsBoxId;
    }

    public void setGoodsBoxId(int goodsBoxId) {
        if(this.goodsBoxId != goodsBoxId) {
            this.goodsBoxId = goodsBoxId;
            setUpdateOption();
        }
    }

    public int getOpenTimes() {
        return openUserIdList.size();
    }

    public List<Long> getOpenUserIdList() {
        return openUserIdList;
    }

    public void setOpenUserIdList(List<Long> openUserIdList) {
        this.openUserIdList = openUserIdList;
        setUpdateOption();
    }

    public String getOpenUserIdListString(){
        return StringUtils.listToString(openUserIdList, ',');
    }

    public boolean isUserOpenBox(long userId){
        return openUserIdList.contains(userId);
    }

    public void addOpenUserId(long userId){
        if(!isUserOpenBox(userId)){
            openUserIdList.add(userId);
            setUpdateOption();
        }
    }

    public List<HuntBoxReward> getHuntBoxRewardList() {
        return huntBoxRewardList;
    }

    public void setHuntBoxRewardList(List<HuntBoxReward> huntBoxRewardList) {
        this.huntBoxRewardList = huntBoxRewardList;
    }
}
